home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 3006 / 3006.xpi / chrome / dwhelper.jar / content / video-format.xul < prev    next >
Extensible Markup Language  |  2010-01-15  |  4KB  |  119 lines

  1. <?xml version="1.0"?> 
  2. <!-- *****************************************************************************
  3.  *            Copyright (c) 2006-2009 Michel Gutierrez. All Rights Reserved.
  4.  ****************************************************************************** -->
  5. <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> 
  6. <?xml-stylesheet href="chrome://dwhelper/skin/dwhelper.css" type="text/css"?>
  7. <?xml-stylesheet href="chrome://dwhelper/content/bindings.css" type="text/css"?>
  8.  
  9. <!DOCTYPE window SYSTEM "chrome://dwhelper/locale/dwhelper.dtd" >
  10.  
  11. <dialog id="dwhelper-output-video-format"
  12.         title="&title.output-video-format;"
  13.         flex="1"
  14.         onload="onLoad()"
  15.         ondialogaccept="return doOk();"
  16.         ondialoghelp="return doHelp();"
  17.         buttons="help,accept,cancel"
  18.         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  19.         xmlns:html="http://www.w3.org/1999/xhtml"
  20.         >
  21.         
  22.     <popupset>
  23.         <popup id="videoformat-popup" onpopupshowing="onPopupShowing()">
  24.             <menuitem label="&menu.video-format.copy;" oncommand="copyFormat()"/>
  25.             <menuitem label="&menu.video-format.paste;" oncommand="pasteFormat()" id="paste-entry"/>
  26.         </popup>
  27.     </popupset>
  28.  
  29.     <script type="application/x-javascript"
  30.         src="chrome://dwhelper/content/dwhutil.js" />
  31.  
  32.     <script type="application/x-javascript">
  33. <![CDATA[
  34.  
  35. function onLoad() {
  36.     var data=window.arguments[0];
  37.     data.ok=false;
  38.     this.document.getElementById("format");
  39.     document.getElementById("format").value=data.format;
  40. }
  41.  
  42. function doOk() {
  43.     var data=window.arguments[0];
  44.     data.format=document.getElementById("format").value;
  45.     data.ok=true;
  46.     return true;
  47. }
  48.  
  49. function copyFormat() {
  50.     var str = Components.classes["@mozilla.org/supports-string;1"].
  51.         createInstance(Components.interfaces.nsISupportsString); 
  52.     if (!str) return; 
  53.     var text=document.getElementById("format").value;
  54.     str.data = text; 
  55.     var trans = Components.classes["@mozilla.org/widget/transferable;1"].
  56.         createInstance(Components.interfaces.nsITransferable);
  57.     if (!trans) return; 
  58.     trans.addDataFlavor("text/unicode"); 
  59.     trans.setTransferData("text/unicode",str,text.length * 2); 
  60.     var clipid = Components.interfaces.nsIClipboard; 
  61.     var clip = Components.classes["@mozilla.org/widget/clipboard;1"].
  62.         getService(clipid); 
  63.     if (!clip) return; 
  64.     clip.setData(trans,null,clipid.kGlobalClipboard);
  65. }
  66.  
  67. function pasteFormat() {
  68.     var format=getFormatFromClipboard();
  69.     if(format)
  70.         document.getElementById("format").value=format;
  71. }
  72.  
  73. function getFormatFromClipboard() {
  74.     try {
  75.         var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(Components.interfaces.nsIClipboard); 
  76.         if (!clip) return null; 
  77.         var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable); 
  78.         if (!trans) return null; 
  79.         trans.addDataFlavor("text/unicode");
  80.     
  81.         clip.getData(trans,clip.kGlobalClipboard); 
  82.         var str = new Object(); 
  83.         var strLength = new Object(); 
  84.         trans.getTransferData("text/unicode",str,strLength);
  85.         
  86.         str = str.value.QueryInterface(Components.interfaces.nsISupportsString); 
  87.         str = str.data.substring(0,strLength.value / 2);
  88.     
  89.         if(/^\S+\/((\s*-\S+(\s+\S+)?)+){1,2}$/.test(str))
  90.             return str;
  91.         else
  92.             return null;
  93.     } catch(e) { 
  94.         return null; 
  95.     }
  96. }
  97.  
  98. function onPopupShowing() {
  99.     var format=getFormatFromClipboard();
  100.     var pasteEntry=document.getElementById("paste-entry");
  101.     if(format)
  102.         pasteEntry.setAttribute("hidden","false");
  103.     else
  104.         pasteEntry.setAttribute("hidden","true");
  105. }
  106.  
  107. function doHelp() {
  108.     window.opener.open("http://www.downloadhelper.net/conversion-manual.php#details");
  109.     return false;
  110. }
  111.  
  112.  
  113. ]]>
  114.     </script>
  115.  
  116.     <NamedVideoFormat id="format" context="videoformat-popup"/>
  117.     
  118. </dialog>
  119.